package bean.dao;

import hbt.HibernateUtil;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import bean.FormaDePago;

public class FormaDePagoDAO {
	private static FormaDePagoDAO instancia = null;
	private static SessionFactory sf = null;

	public static FormaDePagoDAO getInstancia(){
		if(instancia == null){
			sf = HibernateUtil.getSessionFactory();
			instancia = new FormaDePagoDAO();
		} 
		return instancia;
	}
	
	public FormaDePago buscarFormaDePago(String cuil, String tipo){
		FormaDePago formaDePago = new FormaDePago();
		Session session = sf.openSession();
		Query query = session.createQuery("from FormaDePago fp where (fp.cliente.cuil=:cuil) and (fp.nombre=:nombre)");
		query.setParameter("nombre", tipo);
		query.setParameter("cuil", cuil);
		formaDePago = (FormaDePago) query.uniqueResult();
		session.close();
		return formaDePago;
	}
	
}
